/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.drone.recorder.picture;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import fr.uha.ensisa.jmp.drone.recorder.FileWriter;


public class PictureWriter extends FileWriter<BufferedImage>
{
	private String format;
	protected File file;

	public PictureWriter(String format)
	{
		this.format = format;
	}
	
	public String getFormat()
	{
		return this.format;
	}

	public void setFormat(String format)
	{
		this.format = format;
	}

	@Override
	public void open() throws IOException
	{
		this.file = new File(this.path + "." + this.format);		
	}

	@Override
	public void close() throws IOException
	{		
	}

	@Override
	public void write(BufferedImage record) throws IOException
	{
		ImageIO.write(record,this.format, this.file);
	}
	
}
